<html>
<head><meta charset="utf-8"><title>Getting a span in a string literal from the parsed string · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20a.20span.20in.20a.20string.20literal.20from.20the.20parsed.20string.html">Getting a span in a string literal from the parsed string</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="245482335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20a%20span%20in%20a%20string%20literal%20from%20the%20parsed%20string/near/245482335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> asquared31415 <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20a.20span.20in.20a.20string.20literal.20from.20the.20parsed.20string.html#245482335">(Jul 09 2021 at 18:48)</a>:</h4>
<p>I am trying to implement a lint in the asm macro to warn about the usage of a named label.  I can search for the template string just fine, but I can't figure out how to translate that to a span inside the source representation.<br>
For example if it's a raw string, or the string has escape characters, the offsets are wrong.  Using the source string is hard because I still would need to parse escape characters, and also deal with the double quotes or other source characters that I need to interpret as the actual produced string.<br>
What would be the best way to find the right span in the source from positions in the parsed string?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>